<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const sum = (...args) => {
            let total = 0;
            args.forEach(item => {    //回调函数不熟悉
                //item就是一个形参，它是forEach的第一个形参代表的是数组里面的值
                total += item;

            })
            return total;

        };
        console.log(sum(10, 20));
        console.log(sum(10, 20, 30));


        //剩余参数和结构配合使用
        let ary1 = ['张三', '李四', '王五'];
        let [s1, ...s2] = ary1;
        console.log(s1);
        console.log(s2);  //打印剩余的数组中的值


    </script>
</body>

</html>